Attribute VB_Name = "Workshop"
Public Function runGroovy(internalPath As String, entry As String, arg As String) As Integer
  jarPath = """" & internalPath & "\groo.jar" & """"
  
  With VBA.CreateObject("WScript.Shell")
    runGroovy = .run("java -jar " & jarPath & " --excel --entry " & entry & " " & arg, 1, True)
  End With
End Function

Public Function getAllCells(sheet As Worksheet) As Range
 Set getAllCells = sheet.Range(sheet.Cells(1), getLastCell(sheet))
End Function

Public Function getLastCell(sheet As Worksheet) As Range
 Set getLastCell = sheet.Cells.SpecialCells(xlLastCell)
End Function

Public Function vLookUp(sheet As Worksheet, lookup As String, offset As Integer) As Range
 Dim valueCell As Range
 
 Set valueCell = sheet.Cells.Find(What:=lookup)
 Set valueCell = sheet.Cells(valueCell.row, valueCell.Column + offset)
 
 Set vLookUp = valueCell
End Function

Public Sub closeWithoutSave(book As Workbook)
 book.Saved = True
 book.Close
End Sub

Public Sub importCsv(csvPath As String, toSheet As Worksheet)
 Dim csvBook As Workbook
 Set csvBook = Workbooks.Open(csvPath)
 getAllCells(csvBook.ActiveSheet).Copy
 
 With toSheet
  .Activate
  .Cells(1).Select
  .Paste
 End With
 
 csvBook.Activate
 Application.CutCopyMode = False
 Call closeWithoutSave(csvBook)
End Sub
